<?php

class Event_model extends CI_Model {
	
	function __construct()	{
      parent::__construct();
   }
	
	public function record_count() {
        return $this->db->count_all("event");
    }
   
    public function show_latest() {
    	$this->load->database();
    	$this->db->select('*');
    	$this->db->from('event');
    	$this->db->join('members', 'event.postId = members.id');
    	$this->db->order_by("id", "desc"); 
    	$this->db->limit(1);
    	$query = $this->db->get();
    	return $query->result();
    }
    
   public function show_all_achievements() {
   	$this->load->database();
   	$this->db->select('*');
   	$this->db->from('achievement');
   	$this->db->join('members', 'achievement.memId = members.id');
   	$this->db->join('dept', 'members.dept = dept.deptId');
	$this->db->order_by("postDate", "asc");
   	$query = $this->db->get();
   	//print_r($this->db->last_query());
   	return $query->result();
   }
   
   public function show_job($id) {
   	$this->load->database();
   	$this->db->select('*');
   	$this->db->from('job');
   	$this->db->join('members', 'job.postedId = members.id');
   	$this->db->where('jobId', $id);
   	$query = $this->db->get();
   	return $query->result();
   }
   
}

